<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019\6\13 0013
 * Time: 22:07
 */

namespace BigVideo\IMooc\Strategy;

/**
 * 策略模式  一组特定的行为或者算法封装成类 以适用某中特需的上下文----
 * Class Index
 * @package BigVideo\IMooc\Strategy
 */
class Index
{
    /**
     * @var UserStrategy
     */
    protected $strategy;
    public function pageAction(){
        switch ($_GET['name']){
            case "male":
                $this->setStrategy(new MaleUserStrategy());
                break;
            case "female":
                $this->setStrategy(new FemaleUserStrategy());
        }
        $this->strategy->showAd();
        $this->strategy->showCategory();
    }

    public function setStrategy(UserStrategy $strategy){
        $this->strategy = $strategy;
    }
}